package com.hzz.framework.fileServer.baidu.ueditor.upload;

import com.hzz.framework.fileServer.baidu.ueditor.define.State;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Component
public class Uploader {
    private HttpServletRequest request = null;
    private Map<String, Object> conf = null;

    public Uploader init(HttpServletRequest request, Map<String, Object> conf) {
        this.request = request;
        this.conf = conf;
        return this;
    }

    public final State doExec() {

        State state = null;

        if ("true".equals(this.conf.get("isBase64"))) {
            state = Base64Uploader.save(this.request, this.conf);
        } else {
            state = BinaryUploader.save(this.request, this.conf);
        }

        return state;
    }
}
